package producers;
import codeComposition.*;
import util.*;

public class SettingProducer implements Producer {
	
	String name;
	ModelElement me;
	public SettingProducer(String name){
		this.name = name;
		me = new ModelElement(name);
		SimpleExpressionElement see = new SimpleExpressionElement();
		see.add(new VarAssignElement("'"+name+"'", "BOT_NAME").getRawString());
		see.add(new VarAssignElement("'1.0'", "BOT_VERSION").getRawString());
		see.add("");
		see.add(new VarAssignElement("['"+name+".spiders']", "SPIDER_MODULES").getRawString());
		see.add(new VarAssignElement("'"+name+".spiders'", "NEWSPIDER_MODULE").getRawString());
		see.add(new VarAssignElement("'"+name+".items."+StringHelper.firtCharToUpperCase(name)+"Item"+"'", 
				"DEFAULT_ITEM_CLASS").getRawString());
		see.add("USER_AGENT = '%s/%s' % (BOT_NAME, BOT_VERSION)");
		see.add("ITEM_PIPELINES = [" + 
				"'"+name+".pipelines."+StringHelper.firtCharToUpperCase(name)+"Pipeline'");
		see.add("\t]");
		me.addExpression(see);		
	}
	public String produce(){
		return me.toString();
	}
}
